package org.alala.user.data.models.result;

import java.util.Properties;

public final class Results {

	private Results() {
	}
	
	public static OKResult<?> newOkResult() {

		OKResult<?> result = new OKResult<>();

		result.setCode(ResultCode.OK.getCode());
		result.setDesc(ResultCode.OK.getDesc());
		
		return result;
	}

	public static <T> OKResult<T> newOkResult(T data) {

		OKResult<T> result = new OKResult<>();

		result.setCode(ResultCode.OK.getCode());
		result.setDesc(ResultCode.OK.getDesc());
		result.setData(data);

		return result;
	}

	public static ErrorResult newErrorResult(ResultCode code) {

		ErrorResult errorResult = new ErrorResult();

		errorResult.setCode(code.getCode());
		errorResult.setDesc(code.getDesc());

		return errorResult;
	}

	public static ErrorResult newErrorResult(ResultCode code, Exception exp) {

		ErrorResult errorResult = new ErrorResult();

		errorResult.setCode(code.getCode());
		errorResult.setDesc(code.getDesc());
		errorResult.setException(exp);

		return errorResult;

	}

	public static ErrorResult newErrorResult(ResultCode code, Exception exp, Properties props) {

		ErrorResult errorResult = new ErrorResult();

		errorResult.setCode(code.getCode());
		errorResult.setDesc(code.getDesc());
		errorResult.setException(exp);
		errorResult.setProps(props);

		return errorResult;
		
	}
}
